﻿using OF.Utility;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Optimization;
using System.Web.Routing;

namespace CGT.GOP
{
    public class MvcApplication : System.Web.HttpApplication
    {
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);

            Application.Lock();
            Application["UserCount"] = 0;
            Application.UnLock();
        }


        /// <summary>
        /// 单个用户事件开始
        /// </summary>
        protected void Session_Start()
        {
            Application.Lock();
            int online = (int)Application["UserCount"];
            Application["UserCount"] = online + 1;
            Session["LoginDate"] = DateTime.Now;
            Application.UnLock();
        }
        /// <summary>
        /// 单个用户事件结束
        /// </summary>
        protected void Session_End()
        {
            Application.Lock();
            int online = (int)Application["UserCount"];
            Application["UserCount"] = online - 1;
            Application.UnLock();
            SSOHelper.GlobalSessionEnd();
        }
    }
}
